package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-08-17 15:31
 */
public class QOffer22 {
    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode fast = head, slow = head;
        int index = 0;
        while (fast != null) {
            fast = fast.next;
            if(index >= k) {
                slow = slow.next;
            }
            index++;
        }

        return slow;
    }
}
